import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import iboxHead from '../components/iboxHead.vue'
import search from '../components/search.vue'
import swiper from '../components/swiper.vue'
import home from '../components/home.vue'
import iboxFooter from '../components/iboxFooter.vue'
import login from "../components/login.vue"
import market from "../components/market.vue"
import blindbox from "../components/blindbox.vue"
import mine from "../components/mine.vue"
import detail from "../components/detail.vue"
import detailBlindbox from "../components/detailBlindbox.vue"
/*配置路由*/

const routes = [{
		path: "/iboxHead",
		component: iboxHead
	},
	{
		path: "/swipe",
		component: swiper
	},
	{
		path: "/home",
		component: home
	},
	{
		path: "/iboxFooter",
		component: iboxFooter
	},
	{
		path: "/login",
		components:{ login}
	},
	{
		name:"market",
		path:"/market",
		components:{
			iboxHead,
			search,
			market
			}
		
	},
	{
		path:"/blindbox",
		components:{
			iboxHead,
			search,
			blindbox
		}
	},
	{
		path:"/mine",
		components:{
			iboxHead,
			mine,
		}
	},
	
	{
		name:"detail",
		path:'/detail',
		components:{
			iboxHead,
			detail
		}
	},
	{
		name:"detailBlindbox",
		path:'/detailBlindbox',
		components:{
			iboxHead,
			detailBlindbox
		}
	},
	{
		path: "/",
		components: {
			iboxHead,
			search,
			swiper,
			home,
			iboxFooter
		}
	}

]

/*实例化路由*/
const router = new VueRouter({
	routes // （简写）相当于 routes: routes
})
//解决vue路由重复导航错误
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}
/*导出路由模块*/
export default router
